package top.jacktgq.itheima.netty.protocol_design.groupchat.message;

import io.netty.channel.ChannelHandlerContext;
import lombok.Data;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

import java.util.Set;

@Data
@ToString(callSuper = true)
@Slf4j
public class GroupMembersResponseMessage extends Message {

    private String groupName;
    private Set<String> members;

    public GroupMembersResponseMessage() {
    }

    public GroupMembersResponseMessage(String groupName, Set<String> members) {
        this.groupName = groupName;
        this.members = members;
    }

    @Override
    public int getMessageType() {
        return GroupMembersResponseMessage;
    }

    @Override
    public void handle(ChannelHandlerContext ctx) {
        if (members.size() > 0) {
            log.debug("{} 群成员：{}", groupName, members);
        } else {
            log.debug("群 {} 不存在", groupName);
        }
    }
}
